<template>
  <div class="edit-stock-warpper">
    <el-form
      ref="ruleform"
      :inline="true"
      :model="form"
      :rules="rules"
      label-width="100px"
    >
      <el-row>
        <el-form-item label="修改方式：" label-width="84">
          <el-radio-group v-model="form.edit_type" v-removeAriaHidden>
            <el-radio v-for="item in pageInfo.typeArr" :key="item.value" :label="item.value" :class="item.value === 1 ? 'editTypeTwo' : ''">
              {{ item.label }}
              <el-input v-if="item.value === 0" v-model.number="form.new_stock" size="mini" placeholder="1-999999999的整数" style="width: 240px; margin-left: 8px;" />
              <el-input v-if="item.value === 1" v-model.number="form.add_stock" size="mini" placeholder="0-999999999的整数" style="width: 240px; margin-left: 8px;" />
              <div v-if="item.value === 2" style="display: inline-block; color: #000;">
                <el-input v-model="form.dec_stock" size="mini" placeholder="请输入" style="width: 100px; margin: 0 8px;" />
                <span>减后结果不少于</span>
                <el-input v-model="form.min_stock" size="mini" placeholder="请输入" style="width: 100px; margin: 0 8px;" />
              </div>
            </el-radio>
          </el-radio-group>
        </el-form-item>
      </el-row>
      <el-row>
        <el-form-item label="排除设置：" label-width="84">
          <el-checkbox v-model="form.checked" style="margin-right: 8px;" />
          <span>当SKU库存数量少于等于</span>
          <el-input v-model="form.exclude_stock" size="mini" placeholder="请输入" style="width: 100px; margin: 0 8px 0 4px" />
          <span>时，不做修改</span>
        </el-form-item>
      </el-row>
    </el-form>
  </div>
</template>

<script>
export default {
  data() {
    return {
      pageInfo: {
        typeArr: [
          {
            label: '统一库存',
            value: 0
          },
          {
            label: '库存增加',
            value: 1
          },
          {
            label: '库存减少',
            value: 2
          }
        ]
      },
      form: {
        edit_type: 0,
        new_stock: '',
        add_stock: '',
        dec_stock: '',
        min_stock: '',
        checked: true,
        exclude_stock: ''
      },
      rules: {}
    }
  },
  methods: {
    addDomain() {
      this.form.replaceKeywords.push({
        replaceBefore: '',
        replaceAfter: ''
      })
    },
    removeDomain(item) {
      var index = this.form.replaceKeywords.indexOf(item)
      if (index !== -1) {
        this.form.replaceKeywords.splice(index, 1)
      }
    }
  }
}
</script>

<style lang="scss" scoped>
p {
  margin: 0;
  line-height: 17px;
}
.edit-stock-warpper {
  ::v-deep {
    .el-radio {
      display: block;
      margin-top: 12px;
      &:first-of-type {
        margin-top: 4px;
      }
    }
  }
}
</style>
